
cc.Class({
    extends: cc.Component,

    properties: {
        audio: cc.AudioClip,
    },



    onLoad() {
        this.coinSpeed = -100;
        this.coinMgrJs = this.node.parent.getComponent("CoinMgr");
        let scoreNode = cc.find("Canvas/score");
        this.scoreNodeJs = scoreNode.getComponent("Score");

    },
    start() {

    },

    update(dt) {
        this.node.x += this.coinSpeed * dt;
        if (this.node.x <= (-cc.winSize.width / 2 - this.node.width)) {
            this.node.removeFromParent();
        }

    },
    onBeginContact: function (contact, selfCollider, otherCollider) {
        if (otherCollider.node.group === "player") {
            cc.audioEngine.playEffect(this.audio, false);
            this.scoreNodeJs.updateScore(1);
            this.node.removeFromParent();
        }
    },

});
